Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

leaflet

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

leaflet

JavaScript library for mobile-friendly interactive maps

  • 0.7.7
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.2M
increased by4.09%
Maintainers
1
Weekly downloads
 
Created

What is leaflet?

Leaflet is a widely used open-source JavaScript library that helps you create mobile-friendly interactive maps. It provides features that allow users to embed maps into web pages, add various types of layers, markers, popups, and handle user interactions with the map.

What are leaflet's main functionalities?

Map Initialization

This code initializes a new map in the 'mapid' HTML element and sets the view to a specific latitude and longitude and a zoom level.

var map = L.map('mapid').setView([51.505, -0.09], 13);

Tile Layer

This code adds a tile layer to the map using OpenStreetMap tiles. It sets the maximum zoom level and adds attribution text.

L.tileLayer('https://{s}.tile.openstreetmap.org/{z}/{x}/{y}.png', {
  maxZoom: 19,
  attribution: '© OpenStreetMap contributors'
}).addTo(map);

Markers

This code places a marker on the map at the specified latitude and longitude.

var marker = L.marker([51.5, -0.09]).addTo(map);

Popups

This code binds a popup with some HTML content to the previously created marker and opens it.

marker.bindPopup('<b>Hello world!</b><br>I am a popup.').openPopup();

GeoJSON

This code adds a GeoJSON layer to the map. The 'geojsonData' variable should contain valid GeoJSON.

L.geoJSON(geojsonData).addTo(map);

Other packages similar to leaflet

Keywords

FAQs

Package last updated on 26 Oct 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc